package com.szeldon.meteodroid;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;

public class MeteogramActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.meteorogram);
    }

    @Override
    protected void onResume() {
        super.onResume();

        WebView webView = (WebView) findViewById(R.id.webview);

        Intent intent = getIntent();
        if (intent == null) {
            webView.loadData("use main activity!", "text/html", "UTF-8");
        } else {
            String modelType = intent.getStringExtra(MeteoPlHelper.MODEL_TYPE_ARGUMENT_KEY);
            String forecastDate = intent.getStringExtra(MeteoPlHelper.FORECAST_DATE_ARGUMENT_KEY);
            int row = intent.getIntExtra(MeteoPlHelper.ROW_ARGUMENT_KEY, -1);
            int column = intent.getIntExtra(MeteoPlHelper.COLUMN_ARGUMENT_KEY, -1);
            String language = intent.getStringExtra(MeteoPlHelper.LANGUAGE_ARGUMENT_KEY);
            String cityName = intent.getStringExtra(MeteoPlHelper.CITY_NAME_ARGUMENT_KEY);

            webView.loadUrl("http://new.meteo.pl/um/php/meteorogram_list.php?+" + MeteoPlHelper.MODEL_TYPE_ARGUMENT_KEY
                    + "=" + modelType + "&" + MeteoPlHelper.FORECAST_DATE_ARGUMENT_KEY + "=" + forecastDate + "&"
                    + MeteoPlHelper.ROW_ARGUMENT_KEY + "=" + row + "&" + MeteoPlHelper.COLUMN_ARGUMENT_KEY + "="
                    + column + "&" + MeteoPlHelper.LANGUAGE_ARGUMENT_KEY + "=" + language + "&"
                    + MeteoPlHelper.CITY_NAME_ARGUMENT_KEY + "=" + cityName);
        }

    }
}
